// ============================== 路由配置 =============================

// 引用文件
import Layout from "@/layout";

/**
 * 默认常驻路由
 * 此区域路由会一直在左侧菜单展示
 */
export const constantRoutes = [
  // 默认路由
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index"),
      },
    ],
  },
  {
    path: "/auth-redirect",
    component: () => import("@/views/login/auth-redirect"),
    hidden: true,
  },
  {
    path: "/notfound",
    component: () => import("@/views/system/notfound/index"),
    hidden: true,
  },
  // 登录页
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  // 首页
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        component: () => import("@/views/dashboard/index"),
        name: "dashboard",
        meta: {
          title: localStorage.getItem('language') === 'zh_CN' ? "首页" : "Home",
          icon: "el-icon-menu",
          affix: true,
        },
      },
    ],
  },

  // 流程管理
  {
    name: 'flow',
    path: "/flow",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "流程管理",
      icon: "el-icon-cpu"
    },
    children: [
      {
        path: "assemblyLibrary",
        component: () => import("@/views/flow/assemblyLibrary/index"),
        name: "assemblyLibrary",
        meta: {
          title: "组件库管理"
        }
      },
      {
        path: "assemblyLibrary/create",
        component: () => import("@/views/flow/assemblyLibrary/create"),
        name: "assemblyLibrary-create",
        meta: {
          title: "组件库新增"
        },
        hidden:true,
      },
      {
        path: "assemblyLibrary/edit/:id",
        component: () => import("@/views/flow/assemblyLibrary/create"),
        name: "assemblyLibrary-edit",
        meta: {
          title: "组件库编辑"
        },
        hidden:true,
      },
      {
        path: "assemblyLibrary/assembly/:classifyId",
        component: () => import("@/views/flow/assemblyLibrary/assembly/index"),
        name: "assembly",
        meta: {
          title: "组件管理"
        },
        hidden:true,
      },
      {
        path: "assemblyLibrary/assembly/:classifyId/create",
        component: () => import("@/views/flow/assemblyLibrary/assembly/create"),
        name: "assembly-create",
        meta: {
          title: "组件新增"
        },
        hidden:true,
      },
      {
        path: "assemblyLibrary/assembly/:classifyId/edit/:id",
        component: () => import("@/views/flow/assemblyLibrary/assembly/create"),
        name: "assembly-edit",
        meta: {
          title: "组件编辑"
        },
        hidden:true,
      },
      {
        path: "assemblyLibrary/attribute/:assemblyConfigId",
        component: () => import("@/views/flow/assemblyLibrary/attribute/index"),
        name: "attribute",
        meta: {
          title: "组件属性管理"
        },
        hidden:true,
      },
      {
        path: "assemblyLibrary/attribute/:assemblyConfigId/create",
        component: () => import("@/views/flow/assemblyLibrary/attribute/create"),
        name: "attribute-create",
        meta: {
          title: "组件属性新增"
        },
        hidden:true,
      },
      {
        path: "assemblyLibrary/attribute/:assemblyConfigId/edit/:id",
        component: () => import("@/views/flow/assemblyLibrary/attribute/create"),
        name: "attribute-edit",
        meta: {
          title: "组件属性编辑"
        },
        hidden:true,
      },
      {
        path: "experimentTemplate",
        component: () => import("@/views/flow/experimentTemplate/index"),
        name: "experimentTemplate",
        meta: {
          title: "实验模板管理"
        }
      },
      {
        path: "experimentTemplate/create",
        component: () => import("@/views/flow/experimentTemplate/create"),
        name: "experimentTemplate-create",
        meta: {
          title: "实验模板新增"
        },
        hidden:true,
      },
      {
        path: "experimentTemplate/edit/:templateid/:id/:type",
        component: () => import("@/views/flow/experimentTemplate/create"),
        name: "experimentTemplate-edit",
        meta: {
          title: "实验模板编辑"
        },
        hidden:true,
      },

    ]
  },

];

/**
 * 异步路由
 * 此区域路由会动态从云端加载
 */
export const asyncRoutes = [
  // 自动化实验
  {
    name: 'automation_experiment',
    path: "/automation_experiment",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "自动化实验",
      icon: "el-icon-set-up"
    },
    children: [
      {
        path: "task_overview",
        component: () => import("@/views/automation_experiment/task_overview/index"),
        name: "task_overview",
        meta: {
          title: "任务进程总览"
        }
      },
      {
        path: "monitor",
        component: () => import("@/views/automation_experiment/task_overview/monitor/index"),
        name: "monitor",
        meta: {
          title: "实景监控"
        },
        hidden:true,
      },
      {
        path: "own_create_task",
        component: () => import("@/views/automation_experiment/own_create_task/index"),
        name: "own_create_task",
        meta: {
          title: "自主创建任务"
        }
      },
      {
        path: "template_create_task",
        component: () => import("@/views/automation_experiment/template_create_task/index"),
        name: "templateCreateTask",
        meta: {
          title: "模板创建任务"
        }
      },
      {
        path: "template_create_task/create",
        component: () => import("@/views/automation_experiment/template_create_task/create"),
        name: "templateCreateTask-create",
        meta: {
          title: "模板创建任务-新增模板"
        },
        hidden:true,
      },
      {
        path: "template_create_task/edit/:templateid/:id/:type",
        component: () => import("@/views/automation_experiment/template_create_task/create"),
        name: "templateCreateTask-edit",
        meta: {
          title: "模板创建任务-编辑模板"
        },
        hidden:true,
      },
      {
        path: "experiment_data",
        component: () => import("@/views/automation_experiment/experiment_data/index"),
        name: "experiment_data",
        meta: {
          title: "实验数据管理"
        }
      },
      {
        path: "experiment_data/detail/:id",
        component: () => import("@/views/automation_experiment/experiment_data/detail"),
        name: "experiment_data_detail",
        meta: {
          title: "实验数据详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state",
        component: () => import("@/views/automation_experiment/experiment_running_state/index"),
        name: "experiment_running_state",
        meta: {
          title: "设备运行状态"
        }
      },
      {
        path: "experiment_running_state/autoGuideVehicle",
        component: () => import("@/views/automation_experiment/experiment_running_state/autoGuideVehicle"),
        name: "experiment_running_state_autoGuideVehicle",
        meta: {
          title: "设备运行状态-AGV小车状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/ballMillingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/ballMillingStation"),
        name: "experiment_running_state_ballMillingStation",
        meta: {
          title: "设备运行状态-球磨机1状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/ballMillingTwoStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/ballMillingTwoStation"),
        name: "experiment_running_state_ballMillingTwoStation",
        meta: {
          title: "设备运行状态-球磨机2状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/bottomFurnaceStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/bottomFurnaceStation"),
        name: "experiment_running_state_bottomFurnaceStation",
        meta: {
          title: "设备运行状态-下装炉状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/capperStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/capperStation"),
        name: "experiment_running_state_capperStation",
        meta: {
          title: "设备运行状态-反应釜开盖机状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/capperTwoStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/capperTwoStation"),
        name: "experiment_running_state_capperTwoStation",
        meta: {
          title: "设备运行状态-试管开盖机状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/crucibleConversionStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/crucibleConversionStation"),
        name: "experiment_running_state_crucibleConversionStation",
        meta: {
          title: "设备运行状态-坩埚转换位状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/crusherStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/crusherStation"),
        name: "experiment_running_state_crusherStation",
        meta: {
          title: "设备运行状态-破碎机状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/electroChemistryTestingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/electroChemistryTestingStation"),
        name: "experiment_running_state_electroChemistryTestingStation",
        meta: {
          title: "设备运行状态-电化学测试仪状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/flourBlendingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/flourBlendingStation"),
        name: "experiment_running_state_flourBlendingStation",
        meta: {
          title: "设备运行状态-高通量配粉设备状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/jakaRobot",
        component: () => import("@/views/automation_experiment/experiment_running_state/jakaRobot"),
        name: "experiment_running_state_jakaRobot",
        meta: {
          title: "设备运行状态-ROBOT机器人状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/magneticPeristalticOthersStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/magneticPeristalticOthersStation"),
        name: "experiment_running_state_magneticPeristalticOthersStation",
        meta: {
          title: "设备运行状态-磁力搅拌捏片蠕动工位状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/ovenStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/ovenStation"),
        name: "experiment_running_state_ovenStation",
        meta: {
          title: "设备运行状态-烘箱工位状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/packagingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/packagingStation"),
        name: "experiment_running_state_packagingStation",
        meta: {
          title: "设备运行状态-封装机工位状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/pipetteDistributionStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/pipetteDistributionStation"),
        name: "experiment_running_state_pipetteDistributionStation",
        meta: {
          title: "设备运行状态-移液配比设备状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/scrapingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/scrapingStation"),
        name: "experiment_running_state_scrapingStation",
        meta: {
          title: "设备运行状态-刷料机设备状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/solidLiquidTestingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/solidLiquidTestingStation"),
        name: "experiment_running_state_solidLiquidTestingStation",
        meta: {
          title: "设备运行状态-固液测试设备状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/solidSolidTestingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/solidSolidTestingStation"),
        name: "experiment_running_state_solidSolidTestingStation",
        meta: {
          title: "设备运行状态-固固测试设备状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/xrdTestingStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/xrdTestingStation"),
        name: "experiment_running_state_xrdTestingStation",
        meta: {
          title: "设备运行状态-XRD测试设备状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/tabletPressStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/tabletPressStation"),
        name: "experiment_running_state_tabletPressStation",
        meta: {
          title: "设备运行状态-压片机设备状态详情"
        },
        hidden:true,
      },
      {
        path: "experiment_running_state/tubeFurnaceStation",
        component: () => import("@/views/automation_experiment/experiment_running_state/tubeFurnaceStation"),
        name: "experiment_running_state_tubeFurnaceStation",
        meta: {
          title: "设备运行状态-管式炉设备状态详情"
        },
        hidden:true,
      },
    ]
  },
  // 材料智能体
  {
    name: 'material_intelligent_agent',
    path: "/material_intelligent_agent",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "材料智能体",
      icon: "el-icon-chat-line-round"
    },
    children: [
      {
        path: "universalBigModel",
        component: () => import("@/views/material_intelligent_agent/universalBigModel/index"),
        name: "universalBigModel",
        meta: {
          title: "通用大模型"
        }
      },
      {
        path: "scienceBigModel",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/index"),
        name: "scienceBigModel",
        meta: {
          title: "科学大模型"
        }
      },
      {
        path: "scienceBigModel/model_catalyze",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_catalyze/index"),
        name: "model-catalyze",
        meta: {
          title: "科学大模型-材料化学-催化大模型"
        },
        hidden:true,
      },
      {
        path: "scienceBigModel/model_battery_material",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_battery_material/index"),
        name: "model-battery-material",
        meta: {
          title: "科学大模型-材料化学-电池材料"
        },
        hidden:true,
      },
      {
        path: "scienceBigModel/model_chemisorption",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_chemisorption/index"),
        name: "model-chemisorption",
        meta: {
          title: "科学大模型-材料化学-化学吸附"
        },
        hidden:true,
      },
      {
        path: "scienceBigModel/model_biomaterial",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_biomaterial/index"),
        name: "model-biomaterial",
        meta: {
          title: "科学大模型-材料化学-生物材料"
        },
        hidden:true,
      },
      {
        path: "scienceBigModel/model_microwave_dielectric",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_microwave_dielectric/index"),
        name: "model-microwave-dielectric",
        meta: {
          title: "科学大模型-材料物理-微波介质"
        },
        hidden:true,
      },
      {
        path: "scienceBigModel/model_ferroelectric_voltage",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_ferroelectric_voltage/index"),
        name: "model-ferroelectric-voltage",
        meta: {
          title: "科学大模型-材料物理-铁电压电"
        },
        hidden:true,
      },
      {
        path: "scienceBigModel/model_layer_material",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_layer_material/index"),
        name: "model-layer-material",
        meta: {
          title: "科学大模型-材料物理-图层材料"
        },
        hidden:true,
      },
      {
        path: "scienceBigModel/model_intraocular_lens",
        component: () => import("@/views/material_intelligent_agent/scienceBigModel/model_intraocular_lens/index"),
        name: "model-intraocular-lens",
        meta: {
          title: "科学大模型-材料物理-人工晶体"
        },
        hidden:true,
      },
    ]
  },
  // 高通量计算
  {
    path: "/",
    component: Layout,
    redirect: "/high_throughput_computing",
    children: [
      {
        path: "high_throughput_computing",
        component: () => import("@/views/high_throughput_computing/index"),
        name: "high_throughput_computing",
        meta: {
          title: "高通量计算",
          icon: "el-icon-cpu",
          affix: true,
        },
      },
      {
        path: "high_throughput_computing/detail/:id",
        component: () => import("@/views/high_throughput_computing/detail"),
        name: "high-throughput-computing-detail",
        meta: {
          title: "高通量计算-计算页面"
        },
        hidden:true,
      },
    ],
  },
  // 材料数据库
  {
    path: "/",
    component: Layout,
    redirect: "/material_database",
    children: [
      {
        path: "material_database",
        component: () => import("@/views/material_database/index"),
        name: "material_database",
        meta: {
          title: "材料数据库",
          icon: "el-icon-coin",
          affix: true,
        },
      },
      {
        path: "material_database/list",
        component: () => import("@/views/material_database/material"),
        name: "material-list",
        meta: {
          title: "材料数据库-材料列表"
        },
        hidden:true,
      },
      {
        path: "material_database/detail/:id",
        component: () => import("@/views/material_database/detail"),
        name: "material-detail",
        meta: {
          title: "材料数据库-材料详情"
        },
        hidden:true,
      },
    ],
  },
  // 数据管理
  {
    name: 'data_manager',
    path: "/data_manager",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "数据管理",
      icon: "el-icon-receiving"
    },
    children: [
      {
        path: "analysis",
        component: () => import("@/views/data_manager/analysis/index"),
        name: "analysis",
        meta: {
          title: "数据分析"
        }
      },
      {
        path: "analysis/detail/:id",
        component: () => import("@/views/data_manager/analysis/detail"),
        name: "analysis-detail",
        meta: {
          title: "数据分析-数据详情"
        },
        hidden:true,
      },
    ]
  },
  // 账户管理
  {
    name: 'account',
    path: "/account",
    component: Layout,
    alwaysShow: true,
    meta: {
      title: "账户管理",
      icon: "el-icon-user"
    },
    children: [
      {
        path: "user",
        component: () => import("@/views/account/user/index"),
        name: "user",
        meta: {
          title: "用户管理"
        }
      },
      {
        path: "user/create",
        component: () => import("@/views/account/user/create"),
        name: "user-create",
        meta: {
          title: "用户新增"
        },
        hidden:true,
      },
      {
        path: "user/edit/:id",
        component: () => import("@/views/account/user/create"),
        name: "user-edit",
        meta: {
          title: "用户编辑"
        },
        hidden:true,
      },
      {
        path: "role",
        component: () => import("@/views/account/role/index"),
        name: "role",
        meta: {
          title: "权限设置"
        }
      },
      {
        path: "role/create",
        component: () => import("@/views/account/role/create"),
        name: "role-create",
        meta: {
          title: "角色新增"
        },
        hidden:true,
      },
      {
        path: "role/edit/:id",
        component: () => import("@/views/account/role/create"),
        name: "role-edit",
        meta: {
          title: "角色编辑"
        },
        hidden:true,
      },
      {
        path: "role/auth/:id",
        component: () => import("@/views/account/role/auth"),
        name: "role-auth",
        meta: {
          title: "角色权限配置"
        },
        hidden:true,
      },
      {
        path: "operationRecord",
        component: () => import("@/views/account/operationRecord/index"),
        name: "operationRecord",
        meta: {
          title: "操作记录"
        }
      },
    ]
  },
  // // 设备状态
  // {
  //   name: 'equipment',
  //   path: "/equipment",
  //   component: Layout,
  //   alwaysShow: true,
  //   meta: {
  //     title: "设备状态",
  //     icon: "el-icon-data-line"
  //   },
  //   children: [
  //     {
  //       name: 'details',
  //       path: "/details",
  //       component: Layout,
  //       alwaysShow: true,
  //       meta: {
  //         title: "设备详情",
  //       },
  //       children: [
  //         {
  //           path: "warning",
  //           component: () => import("@/views/equipment/warning/index"),
  //           name: "warning",
  //           meta: {
  //             title: "设备预警"
  //           }
  //         }
  //       ]
  //     },
  //     {
  //       path: "warning",
  //       component: () => import("@/views/equipment/warning/index"),
  //       name: "warning",
  //       meta: {
  //         title: "设备预警"
  //       }
  //     }
  //   ]
  // },
];

const createRouter = () =>
  new VueRouter({
    // mode: 'history', // 需要服务支持
    scrollBehavior: () => ({
      y: 0,
    }),
    routes: constantRoutes,
  });

const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher;
}

export default router;
